<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">

	<div id="content">
		
		<div id="pageTitle">
			<span class="titlePage">RESPONSÁVEL</span>
		</div>


		<div id="tableContents">
			<h:form id="formShowResponsaveis" >
				<p:commandButton id="newButton" value="#{msg.button_add_responsible}" icon="ui-icon-plusthick" ajax="true" oncomplete="PF('newResponsavelModal').show();" update=":formNewResponsavel" />
				<p:scrollPanel id="scrolPanelTableResponsaveis" mode="native">
					<p:dataTable id="tableResponsaveis" var="responsible" value="#{responsavelBean.responsibles}" rows="10"
						paginator="true" paginatorPosition="bottom"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						row="10"
						filteredValue="#{responsavelBean.filteredResponsibles}">
						
						<p:column filterBy="#{responsible.nome}" headerText="#{msg.label_responsible}" style="text-align:center"
							filterMatchMode="contains">
							<h:outputText value="#{responsible.nome}" />
						</p:column>
						
						<p:column filterBy="#{responsible.cpf}" headerText="#{msg.label_cpf}" style="text-align:center"
							filterMatchMode="contains">
							<h:outputText value="#{responsible.cpf}" />
						</p:column>
						
						<p:column headerText="#{msg.label_header_service}">
							<!-- Link to edit responsible -->
							<p:commandLink id="editResponsible" ajax="true" actionListener="#{responsavelBean.clickOnEditResponsavel(responsible)}" update=":formNewResponsavel">
								<h:graphicImage library="images" value="/css/img/edit.png" title="Editar Responsável" />
							</p:commandLink>
							
							<!-- Link to remove responsible -->
							<p:commandLink actionListener="#{responsavelBean.clickOnDeleteResponsavel(responsible)}" update=":formShowResponsaveis">
								<h:graphicImage library="images" value="/css/img/del.png" title="Remover Responsável" />
						        <p:confirm header="Confirmação" message="Você realmente deseja remover este responsável?" icon="ui-icon-alert" />
						    </p:commandLink>
						    
						    <!-- The dialog to confirm the removal or not -->
							<p:confirmDialog global="true" showEffect="fade">
						        <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
						        <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
						    </p:confirmDialog>
						    
							<h:outputText />
						</p:column>
						
					</p:dataTable>
				</p:scrollPanel>
			</h:form>
		</div>
	</div>
	
	<!-- Includes to call the form to add aluno -->
	<ui:include src="formNewResponsavel.xhtml" />
</ui:composition>